<%#
 Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>

<%-
	local ctrl = require "luci.tools.nwt"
	local devicelist = ctrl.get_devicelist()
-%>
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-16.358.28306-df0d765"></script>
<script type="text/javascript">//<![CDATA[
	
	function iface_delete(id) {
		if (!confirm('确定要删除设备！'))
			return;

		(new XHR()).post('<%=url('admin/nwt/device_delete')%>/' + id, { token: '<%=token%>' },
			function(x) {
				location.href = '<%=url('admin/nwt/device')%>';
			}
		);
	}

//]]></script>

<fieldset class="cbi-section" style="display:none">
	<legend><%:Reconnecting interface%></legend>
	<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
	<span id="ifc-rc-status"><%:Waiting for changes to be applied...%></span>
</fieldset>

<div class="cbi-map">
	<fieldset class="cbi-section">
		<legend>设备列表</legend>

		<table class="cbi-section-table" style="margin:10px; empty-cells:hide">
			<tr class="cbi-section-table-titles">
				<th class="cbi-section-table-cell">设备</th>
				<th class="cbi-section-table-cell" style="text-align:left"><%:Status%></th>
				<th class="cbi-section-table-cell"><%:Actions%></th>
			</tr>
			<%
				for i, device in ipairs(devicelist) do
			%>
				<tr class="cbi-section-table-row cbi-rowstyle-<%=i % 2 + 1%>">
					<td class="cbi-value-field" style="padding:3px">
						<div class="ifacebox">
							<div class="ifacebox-body" style="background-color:#90f090" id="<%=device.address%>-ifc-devices">
								<small><%=device.name%></small><br>
								<small>(<%=device.address%>)</small>
							</div>
						</div>
					</td>
					<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=device.address%>-ifc-description">
						<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;未知&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em>
					</td>
					<td style="width:420px">
						<input type="button" class="cbi-button cbi-button-reset" style="width:100px" onclick="iface_delete('<%=device.address%>')" title="删除设备" value="删除" />
						<input type="button" class="cbi-button cbi-button-edit" style="width:100px" onclick="location.href='<%=url("admin/nwt/device", device.address)%>'" title="<%:Edit this interface%>" value="<%:Edit%>" id="<%=device.address%>-ifc-edit" />
					</td>
				</tr>
			<% end %>
		</table>
		<input type="button" class="cbi-button cbi-button-add" value="添加新设备" onclick="location.href='<%=url("admin/nwt/device_add")%>'" />

	</fieldset>
</div>
<%+footer%>